// JavaScript Document

function changeCardPrev(){
	var cardTaget;
	if($('#card-2').hasClass("hidden")==false){
		
		$('#card-2').fadeOut(500);		
		$('#card-2').addClass("hidden");
	
		$('#card-1').fadeIn(500);
		$('#card-1').removeClass("hidden");
		
		$('#prevImg').addClass("Inactive");
		
		$('#sliderWidthA').css("left","4%");
		$('#sliderWidth').css("width","0%");
		
		return;
		
		
	}
	
	if($('#card-3').hasClass("hidden")==false){
		
		$('#card-3').fadeOut(500);		
		$('#card-3').addClass("hidden");
	
		$('#card-2').fadeIn(500);
		$('#card-2').removeClass("hidden");
		
		$('#nextImg').removeClass("Inactive");
		
		$('#sliderWidthA').css("left","48%");
		$('#sliderWidth').css("width","48%");
		
		return;
	}
}

function changeCardNext(){
	var cardTaget;
	if($('#card-1').hasClass("hidden")==false){
		$('#card-1').fadeOut(500);		
		$('#card-1').addClass("hidden");
	
		$('#card-2').fadeIn(500);
		$('#card-2').removeClass("hidden");
		
		$('#prevImg').removeClass("Inactive");
		
		$('#sliderWidthA').css("left","48%");
		$('#sliderWidth').css("width","48%");
		
		return;
	}
	
	if($('#card-2').hasClass("hidden")==false){
		$('#card-2').fadeOut(500);		
		$('#card-2').addClass("hidden");
	
		$('#card-3').fadeIn(500);
		$('#card-3').removeClass("hidden");
		
		$('#nextImg').addClass("Inactive");
		
		$('#sliderWidthA').css("left","95%");
		$('#sliderWidth').css("width","100%");
		
		return;
	}
}

function changeFoodUp(target){
	$('#col-image-'+target).fadeOut(10);
	$('#col-image-'+target).css("background-image","url(../../image/food/food10.jpg)");
	$('#col-image-'+target).fadeIn(500);
}

function changeFoodDown(target){
	$('#col-image-'+target).fadeOut(10);
	$('#col-image-'+target).css("background-image","url(../../image/food/food8.jpg)");
	$('#col-image-'+target).fadeIn(500);
	
}



	/**
 * 提示消息
 * @param string msg 消息内容
 * @param string type 类型 有三种选项：[error|info|notice]
 */
function message(msg, type){
	var conf = config['message'];
	if(is_undefined(type)){
		var type = 'info';
	}
	var o = $('#message');
	o.html(msg);
	o.attr('class', type);
	if(message_running){
		clearTimeout(message_settime);
		message_bg();
	}else{
		o.fadeIn(conf.fade_time);
	}
	message_running = true;
	message_settime = setTimeout(function(){
		message_running = false;
		var o = $("#message");
		o.fadeOut(config.message.fade_time);
		o.removeClass(message_type);
	}, conf.display_time);
}

/**
 * 执行动画效果 
 */
function message_bg(){
	message_time = 7;
	_message_bg();
}

/**
 * message_bg() 私有函数
 * 执行动画效果
 */
function _message_bg(){
	if(message_time == 0) return;
	var opacity = 1;
	if(message_time % 2 == 0){
		opacity = 0.5;
	}
	message_time--;
	$('#message').fadeTo(150, opacity, _message_bg);
}
	 